<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>三岁博客后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}"/>
    <link rel="stylesheet" href="../../../static/lib/admin/lib/layui-v2.6.3/css/layui.css" th:href="@{/lib/admin/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" href="../../../static/lib/admin/css/public.css" th:href="@{/lib/admin/css/public.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" id="typeEdit">
    <div class="layui-form-item">
        <label class="layui-form-label">分类id</label>
        <div class="layui-input-block" style="width: 100px;">
            <input type="text" name="typeId" lay-verify="required" lay-reqtext="不能为空" value=""
                   class="layui-input"  readonly  unselectable="on">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">分类名称</label>
        <div class="layui-input-block">
            <input type="text" name="typeName" lay-verify="required" lay-reqtext="不能为空" placeholder="分类名称" value=""
                   class="layui-input">
            <tip>填写分类名称。</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="../../../../static/lib/admin/lib/layui-v2.6.3/layui.js" th:src="@{/lib/admin/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            // var index = layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // }, function () {
            //
            //     // 关闭弹出层
            //     layer.close(index);
            //
            //     var iframeIndex = parent.layer.getFrameIndex(window.name);
            //     parent.layer.close(iframeIndex);
            //
            // });

            $.ajax({
                url: '../../page/type/update',
                type: 'post',
                data: {'typeName': data.field.typeName,'typeId': data.field.typeId},
                success: function (suc) {
                    if (suc.code == 200) {
                        layer.msg(suc.msg,{icon:1});
                        // layer.alert(suc.msg, {icon: 1,cancel: function(){
                        //         var index = parent.layer.getFrameIndex(window.name);
                        //         //关闭当前frame
                        //         parent.layer.close(index);
                        //         //刷新页面
                        //         parent.location.reload();
                        //     }}, function () {
                        //     // 获得frame索引
                        //     var index = parent.layer.getFrameIndex(window.name);
                        //     //关闭当前frame
                        //     parent.layer.close(index);
                        //     //刷新页面
                        //     parent.location.reload();
                        // });
                    } else {
                        layer.alert(suc.msg, {icon: 5});
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>